#include <bits/stdc++.h>
using namespace std;
int main()
{
	freopen("color.in","c",stdin);
	freopen("color.out","w",stdout);
	int t;
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		int n,a[200100],cnt=0;
		cin>>n;
		for(int j=1;j<=n;j++) cin>>a[i];
		sort(a+1,a+1+n);
		for(int j=2;j<=n;j++)
		{
			if(a[j]==a[j-1]){
				cnt+=a[j];
				a[j]=0;
				a[j-1]=0;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}
